Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap ca cb channels #93

Merged
merged 5 commits into from
Jan 29, 2024
Merged

swap ca cb channels #93

merged 5 commits into from
Jan 29, 2024

Conversation

sunal1996
Copy link
Contributor

Change the position of CA CB channels for readability and consistency

type=click.Choice(["CNO", "CNOCB", "CNOCBCA", "CNOCBCAQ", "CNOCBCAP"]),
type=click.Choice(["CNO", "CNOCB", "CNOCACB", "CNOCACBQ", "CNOCACBP"]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility, can we add both?

type=click.Choice(["CNO", "CNOCB", "CNOCACB", "CNOCACBQ", "CNOCACBP", "CNOCBCA", "CNOCBCAQ", "CNOCBCAP" ]),

Comment on lines 271 to 276
elif atom_encoder == "CNOCACB":
codec = Codec.CNOCACB()
elif atom_encoder == "CNOCACBQ":
codec = Codec.CNOCACBQ()
elif atom_encoder == "CNOCACBP":
codec = Codec.CNOCACBP()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here maybe let's add both

Copy link
Member

@universvm universvm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few things to change for backward compatibility.

Comment on lines 280 to 284
"CNOCBCA",
"CNOCBCAQ",
"CNOCBCAP",
], f"Expected encoder to be CNO, CNOCB, CNOCBCA, CNOCBCAQ, CNOCBCAP, but got {atom_encoder}"
"CNOCACB",
"CNOCACBQ",
"CNOCACBP",
], f"Expected encoder to be CNO, CNOCB, CNOCACB, CNOCACBQ, CNOCACBP, but got {atom_encoder}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again here.

I would say let's raise a warning if you are using the old encoders saying they are deprecated and will be removed in future versions.

Comment on lines 268 to 283
codec = Codec.CNO()
elif atom_encoder == "CNOCB":
codec = Codec.CNOCB()
elif atom_encoder == "CNOCBCA":
codec = Codec.CNOCBCA()
elif atom_encoder == "CNOCBCAQ":
codec = Codec.CNOCBCAQ()
elif atom_encoder == "CNOCBCAP":
codec = Codec.CNOCBCAP()
elif atom_encoder == "CNOCACB" or atom_encoder == "CNOCBCA":
codec = Codec.CNOCACB()
if atom_encoder == "CNOCBCA":
warnings.warn("CNOCBCA encoding is deprecated and will be removed in future versions, atoms will be encoded as CNOCACB")
elif atom_encoder == "CNOCACBQ" or atom_encoder == "CNOCBCAQ":
codec = Codec.CNOCACBQ()
if atom_encoder == "CNOCBCAQ":
warnings.warn("CNOCBCAQ encoding is deprecated and will be removed in future versions, atoms will be encoded as CNOCACBQ")
elif atom_encoder == "CNOCACBP" or atom_encoder == "CNOCBCAP":
codec = Codec.CNOCACBP()
if atom_encoder == "CNOCBCAP":
warnings.warn("CNOCBCAP encoding is deprecated and will be removed in future versions, atoms will be encoded as CNOCACBP")
else:
assert atom_encoder in [
"CNO",
"CNOCB",
"CNOCACB",
"CNOCACBQ",
"CNOCACBP",
"CNOCBCA",
"CNOCBCAQ",
"CNOCBCAP",
], f"Expected encoder to be CNO, CNOCB, CNOCBCA, CNOCBCAQ, CNOCBCAP, but got {atom_encoder}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we clean up this section to

# Mapping of current atom encoders to their corresponding Codec classes
current_codec_mapping = {
    "CNO": Codec.CNO,
    "CNOCB": Codec.CNOCB,
    "CNOCACB": Codec.CNOCACB,
    "CNOCACBQ": Codec.CNOCACBQ,
    "CNOCACBP": Codec.CNOCACBP
}

# List of deprecated encodings and their replacements
deprecated_encodings = {
    "CNOCBCA": "CNOCACB",
    "CNOCBCAQ": "CNOCACBQ",
    "CNOCBCAP": "CNOCACBP"
}

# Create Codec based on atom_encoder
if atom_encoder in current_codec_mapping:
    codec = current_codec_mapping[atom_encoder]()
elif atom_encoder in deprecated_encodings:
    replacement = deprecated_encodings[atom_encoder]
    codec = current_codec_mapping[replacement]()
    warnings.warn(f"{atom_encoder} encoding is deprecated and will be removed in future versions, "
                  f"atoms will be encoded as {replacement}")
else:
    raise ValueError(f"Unknown atom_encoder: {atom_encoder}")

Copy link
Member

@universvm universvm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny thing

@sunal1996
Copy link
Contributor Author

I made the changes except for the else condition because Click.choice for the -ae already handles this when an atom encoder is not valid.

universvm
universvm previously approved these changes Dec 20, 2023
Copy link
Member

@universvm universvm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@universvm universvm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for formatting!

@ChrisWellsWood ChrisWellsWood merged commit ce7431b into master Jan 29, 2024
4 checks passed
@ChrisWellsWood ChrisWellsWood deleted the cbcaswap branch January 29, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants